package com.test1.mybatis;

import org.junit.Test;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * MybatisGenerator 正常运行会ignore
 * Created by tianjin.lp on 16/8/26.
 */
public class MybatisGenerator {

    @Test
    public void generateMybatisFile() throws Exception {
        List<String> warnings = new ArrayList<String>();
        File configFile = new File(Thread.currentThread().getContextClassLoader().getResource("mybatis/generatorConfig.xml").getFile());
        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(configFile);
        DefaultShellCallback callback = new DefaultShellCallback(true);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
        myBatisGenerator.generate(null);
    }
}
